<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>添加企业</title>
<link href="../css/manageadmin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script type="text/javascript">
function validate(){
  const requiredFields = [
    {id: "companyName", message: "企业名称不能为空！"},
    {id: "companyArea", message: "企业所在地不能为空！"},
    {id: "companySize", message: "企业规模不能为空！"},
    {id: "companyType", message: "企业性质不能为空！"},
    {id: "companyPic", message: "请选择企业宣传图片！"}
  ];

  for(let field of requiredFields) {
    if(!document.getElementById(field.id).value.trim()) {
      alert(field.message);
      document.getElementById(field.id).focus();
      return false;
    }
  }

  // 2. 校验显示排序（如果填写了内容）
  const companySortInput = document.getElementById("companySort");
  if(companySortInput.value.trim() && isNaN(companySortInput.value.trim())) {
    alert("排序值必须是数字！");
    companySortInput.focus();
    return false;
  }

  return true;
}
</script>
</head>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">添加企业</a></li>
  </ul>
</div>
<div class="formbody">
  <div class="usual">
  <form name="frm" action="../CompanyAddServlet" method="post" enctype="multipart/form-data" onsubmit="return validate();">
    <div class="tabson">
      <ul class="forminfo">
      	<li>
          <label>企业名称<b>*</b></label>
          <input name="companyName" type="text" id="companyName" class="dfinput" style="width:518px;"/>
        </li>
        <li>
          <label>企业所在地<b>*</b></label>
          <input name="companyArea" type="text" id="companyArea" class="dfinput" style="width:518px;"/>
        </li>
        <li>
          <label>企业规模<b>*</b></label>
          <input name="companySize" type="text" id="companySize" class="dfinput" style="width:518px;"/>
        </li>
        <li>
          <label>企业性质<b>*</b></label>
          <input name="companyType" type="text" id="companyType" class="dfinput" style="width:518px;"/>
        </li>
        <li>
          <p>企业简介&nbsp;(不超过1000字)</p>
          <textarea class="ckeditor" cols="50" id="companyBrief" name="companyBrief" rows="10"></textarea>
        </li>
        <li>
          <label>企业招聘状态</label>
          <div class="vocation">
            <select name="companyState" class="select3">
              <option value="1">招聘中</option>
              <option value="2">已暂停</option>
              <option value="3">已结束</option>
            </select>
          </div>
        </li>
        <li>
          <label>显示排序<b></b></label>
          <input name="companySort" type="text" class="dfinput" style="width:100px;"/>
        </li>
         <li>
          <label>宣传图片<b>*</b></label>
          <input name="companyPic" id="companyPic" type="file" class="dfinput" style="width:300px; margin-right:5px;"/>
        </li>
        <li>  <label>&nbsp;</label>
          <input name="" type="submit" class="btn" value="添加"/>
        </li>
      </ul>
    </div>
  </form>
  </div>
</div>
</body>
</html>
